<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>点我</button>
</body>
<script>
	document.querySelector("button").onclick = function(){
        const fnName = "ym"+Math.random().toString(36).slice(2)+Date.now();
		window[fnName] = function(num){
			console.log(num)
        }
		const script = document.createElement("script");
		script.src = "http://zhangpeiyue.com/info2?callback="+fnName;
		script.onload = function(){
			// 1- 清除script标签
            document.body.removeChild(script);
			// 2- 清除全局函数
			delete window[fnName];
        }
		document.body.appendChild(script);
	}
</script>
</html>